-
Notifications
You must be signed in to change notification settings - Fork 432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor turbomind attention by precomputing cos/sin #2801
base: main
Are you sure you want to change the base?
Conversation
@@ -81,6 +83,11 @@ void UnifiedDecoder<T>::forwardSelfAttn(T* attn_io, | |||
inputs.insert("h_cu_q_len", {MEMORY_CPU, TYPE_INT32, {batch_size + 1}, h_cu_q_len_}); | |||
inputs.insert("h_cu_k_len", {MEMORY_CPU, TYPE_INT32, {batch_size + 1}, h_cu_k_len_}); | |||
|
|||
if (rotary_emb_) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any case that rotary_emb_
a nullptr?
@@ -59,22 +59,45 @@ struct MoeParam { | |||
std::vector<int> expert_num; | |||
}; | |||
|
|||
enum class RotaryScalingType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RotaryScalingType -> RopeType
|
||
struct InnerYarnRopeParam { | ||
float attention_factor; | ||
float yarn_ramp_inv_factor_div_2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove the prefix "yarn_"
}; | ||
|
||
struct InnerLlama3RopeParam { | ||
float llama3_inv_scaling_factor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the prefix "llama3_" can be removed
Motivation
Calculate cos/sin in advance and reduce the parameters of the prefill/decode kernel